
@extends('Admin.common.header')

<!-- 1.添加meta csrf_token -->
<meta name="csrf-token" content="{{ csrf_token() }}">  
<script src=" {{ asset('./js/jquery-1.8.3.min.js') }} "></script>


<body style="background-color:#7A7A7A;">

<div style="margin-top:87px;color:#FFFFFF;width:98%;margin-bottom:70px;" class="form-horizontal">
	<br/>
	<!-- 页面标记 -->
	<h3 style='color:white;margin-left:122px;margin-top:-30px;color:#D1EEEE' >
		{{ $title or '' }}
	</h3>
	<br/>

	
	<!-- 网站名称 -->
	<div  class="form-group">
		<label class="col-sm-2 control-label">网站名称</label>
		<div class="col-sm-10">
			<input type="text" name="name" value="{{ $link->name or '' }}" class="form-control" style="width:300px;"  placeholder="网站名称" />
		</div>
	</div>

	<div  class="form-group">
		<label class="col-sm-2 control-label">链接地址</label>
		<div class="col-sm-10">
			<input type="text" name="url" value="{{ $link->url or '' }}" class="form-control" style="width:300px;"  placeholder="链接地址" />
		</div>
	</div>
	
	
	<!-- 背景图片 -->
	<div style="position:absolute;left:720px;top:140px;">
		<img src="{{ asset('./images/logo.png') }}" alt="">
	</div>
	<br/>
	
	
	@if( isset($link) )
		<button  style="width:320px;;margin-left:155px;" data-toggle="modal" data-target=".bs-example-modal-sm" class="btn btn-danger" id="">修改
		</button>
	@else
		<button  style="width:320px;margin-left:155px;" data-toggle="modal" data-target=".bs-example-modal-sm" class="btn btn-danger" id="">添加
		</button>
	@endif
	
	
	<div  class="form-group" style="margin-top:20px;">
		<a href="{{ url('/friend/list') }}" style="width:320px;margin-left:170px;" class="btn btn-success">
			列表
		</a>
	</div>
	
	
	<!-- 1.模态框 不要动 -->
	<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
		<div class="modal-dialog modal-sm" role="document" id='show_info'  style="margin-top:80px;margin-left:570px;">
		</div>
	</div>

</div>

<div id="linkId" value="{{ $link->id or ''}}" ></div>
<script>
	<!-- 2.设置全局ajax选项 -->
	$.ajaxSetup({
		headers: {
			'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		}
	});
	var _token = $('meta[name="csrf-token"]').attr('content');

	$(function(){

	
		// 点击 执行 友情链接 创建 编辑
		$("button").click(function(){
			var link_id = $("#linkId").attr('value');
			if( link_id!='' )
			{
				// 编辑
				var sendUrl ="{{ url('/friend/doCreate') }}"+'/'+link_id;
				
			}else
			{
				// 创建
				var sendUrl ="{{ url('/friend/doCreate') }}";
			}
			var name = $("input[name='name']").val();
			var url = $("input[name='url']").val();
			$.ajax({
				type:"post",
				url:sendUrl,
				data:{url:url,name:name,_token:_token},
				async:true,    						
				dataType:"json",
				success:function(back){
					$('#show_info').html( '' );
					$('#show_info').html( back['show_info'] );
					location.reload();
				}
			});
		});

	});
</script>
</body>

@extends('Admin.common.footer')